// Helper method to generate regular expressions used to search
// for fields in JSON docs.
// eg: field = "name" will generate regex to look for "name": "*"

public function formRegExp(field:String):String{
  returnString:String = "//"" + field + "//"://"*/"/";
  return returnString;
}

// Helper method to find a field in a JSON document and 
// return the field's data, eg find "name" might return "Mark Twain"

public function findField(field:String, data:String):String{
  var pattern:RegExp = returnString(field);
  var matchResults:Array = data.match(pattern);
  return matchResults[0];
}

public class Person
{
  public var name:String;
  public var bithday:String;
  public var contact:String;
  public var photoURL:String;
  public var jsonDoc:String;
  
  public function Person(jsonDOC:String){
    name = findFIeld("name", jsonDOC);
    birthday = findField("birthday", jsonDOC);
    contact = findField("email", jsonDOC);
    //TODO: photoURL
    jsonDoc = jsonDOC;
  }
}

public class Group
{
  public var name:String;
  public var category:String;
  public var description:String;
  
  public function Group(jsonDOC:String){
    name = findField("name");
    category = ;
    description = ;
  }
}

//TODO convert all following constructors so that they take a json document
// and extract the class members from that document given fields.

public class App
{
  public var name:String;
  public var category:String;
  
  public function App(appName:String, appCategory:String=""){
    name = appName;
    category = appCategory;
  }
}

public class Event{
  public var name:String;
  public var time:String;
  public var place:String;
  
  public function Event(eventName:String, eventTime:String="", eventPlace:String=""){
    name = eventName;
    time = eventTime;
    place = eventPlace;
  }
}

public class Page{
  public var name:String;
  public var category:String;
  
  public function Page(pageName:String, pageCategory:String=""){
    name = pageName;
    category = pageCategory;
  }
}

public class SearchResultCollection{
  public var personResults:Array;
  public var groupResults:Array;
  public var appResults:Array;
  public var eventResults:Array;
  public var pageResults:Array;
  
  public function SearchResultCollection{
    personResults = new Array();
    groupResults = new Array();
    appResults = new Array();
    eventResults = new Array();
    pageResults = new Array();
  }
}